/*
 * @Description:GWP
 * @Author: qingyang
 * @Date: 2022-05-19 11:28:06
 * @LastEditors: qingyang
 * @LastEditTime: 2023-07-25 19:29:24
 */
import { get, post } from '@/utils/http'
import type { BasicPagingListParams, BasicPagingListResult } from '@/apis/basicModel'
import type {
  IPageMaterialParams,
  IPageMaterialResult,
  IMaterialDrop,
  IUpdateStatusParams,
  IAddMaterial
} from './model/materialModel'

enum Api {
  // GET燃料能源填充物列表
  GET_MATERIAL_LIST = '/inventory/emissionSourceMaterial/pageMaterial',
  GET_MATERIAL_DROP = '/inventory/emissionSourceMaterial/listMaterial',
  UPDATE_ENABLE = '/inventory/emissionSourceMaterial/updateStatus',
  ADD_MATERIAL = '/inventory/emissionSourceMaterial/saveMaterial',
  EDIT_MATERIAL = '/inventory/emissionSourceMaterial/updateMaterial',
  DEL_MATERIAL = '/inventory/emissionSourceMaterial/deleteMaterial'
}

// 燃料能源填充物列表
export const getMaterialList = (
  params: IPageMaterialParams & BasicPagingListParams
): Promise<BasicPagingListResult<IPageMaterialResult>> => get(Api.GET_MATERIAL_LIST, params)

// 燃料能源填充物下拉
export const getMaterialListDrop = (materialName: string): Promise<IMaterialDrop[]> =>
  get(Api.GET_MATERIAL_DROP, { materialName })
// 修改启用状态
export const updateStatus = (params: IUpdateStatusParams): Promise<void> =>
  post(Api.UPDATE_ENABLE, params)

// 新增燃料能源填充物
export const addMaterial = (params: IAddMaterial): Promise<void> => post(Api.ADD_MATERIAL, params)
// 燃料能源填充物修改
export const editMaterial = (params: IAddMaterial): Promise<void> => post(Api.EDIT_MATERIAL, params)
// 删除能源填充物
export const delMaterial = (materialNo: string): Promise<void> =>
  post(Api.DEL_MATERIAL, { materialNo })
